home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / doCopyKeyArgList.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  5.5 KB  |  178 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  10 Aug 98
  22. //  Author:         mw
  23. //
  24. //  Description:
  25. //    doCopyKeyArgList is the actual proc that is executed from the
  26. //    Edit->Keys->Copy Keys option box or menu.
  27. //
  28. //    doCopyKeyArgList allows for a variable number
  29. //    or arguments to be passed in through a string array.
  30. //    This is not possible through the fixed-arg proc doCopyKey
  31. //
  32. //  Input Arguments:
  33. //    $version: The version of this option box.  Used to know how to 
  34. //    interpret the $args array.
  35. //        "1" : $whichRange, $timeRange, $option, $hierarchy,
  36. //                $doControlPoints, $doShapes, $useChannelBox,
  37. //                $selectionConnection
  38. //        "2" : $options
  39. //
  40. //    $args
  41. //    Version 1
  42. //    [0]        $whichRange                1 : time range all
  43. //                                    2 : use playback range
  44. //                                    3 : use $timeRange
  45. //    [1]        $timeRange                startTime:endTime
  46. //    [2]        $option                    keys
  47. //                                    curve
  48. //    [3]        $hierarchy                1 : none
  49. //                                    2 : below
  50. //    [4]        $doControlPoints        0 / 1
  51. //    [5]        $doShapes                0 / 1
  52. //    [6]        $useChannelBox            0 / 1
  53. //    [7]        $selectionConnection    name of selection connection to use
  54. //                                    unless $options has "bufferCurve" in which
  55. //                                    case this is the name of the editor
  56. //    Version 2
  57. //    [8]        $options                a ':' delimited list of options
  58. //                                    noOptions        an empty placeholder
  59. //                                    bufferCurve        create buffer curves
  60. //    Version 3
  61. //    [11]    $fromGraphEditor        0 / 1 
  62. //    [12]    $doDrivenChannels        0 / 1 
  63. //
  64. //  Return Value:
  65. //      The number of curves from which keys were copied.
  66. //
  67. global proc int doCopyKeyArgList( string $version, string $args[] )
  68. {
  69.     int        $versionNum                = $version;
  70.  
  71.     int        $whichRange                = $args[0];
  72.     string    $timeRange                = $args[1];
  73.     string    $option                    = $args[2];
  74.     string    $hierarchy                = $args[3];
  75.     int        $doControlPoints        = $args[4];
  76.     int        $doShapes                = $args[5];
  77.     int        $useChannelBox            = $args[6];
  78.     string    $selectionConnection    = $args[7];
  79.     string    $options                = ($versionNum >= 2 ? $args[8] : "noOptions");    
  80.     int     $fromGraphEditor        = $versionNum >= 3 ? $args[9] : "1";
  81.     int     $doDriven                = $versionNum >= 3 ? $args[10] : "1";
  82.  
  83.     string $cmd = "copyKey ";
  84.     
  85.     string $realConnection = $selectionConnection;
  86.  
  87.     // Check for the bufferCurve option
  88.     //
  89.     if (match ("bufferCurve", $options) == "bufferCurve") {
  90.         $realConnection = `editor -query -mainListConnection $selectionConnection`;
  91.         // Check to see if we need to create buffer curves
  92.         //
  93.         if (`animCurveEditor -query -showBufferCurves $selectionConnection` == "on") {
  94.             $cmd = "bufferCurve -animation \"keys\" -overwrite false; " + $cmd;
  95.         }
  96.     }
  97.  
  98.     // Get the target objects
  99.     //
  100.     string $members = expandSelectionConnection ($realConnection);
  101.  
  102.     int $needOption = true;
  103.     if( $whichRange == 1 ) {
  104.         $timeRange = ":";
  105.         $needOption = false;
  106.     } else if( $whichRange == 2 ) {
  107.         $timeRange = ( `playbackOptions -q -min` + ":" + 
  108.                        `playbackOptions -q -max` );
  109.     }
  110.  
  111.     // Check to see if a time range has been specified.  If no time range,
  112.     // then we don't add the option, since we're doing all the keyframes
  113.     // and an option makes no sense.
  114.     //
  115.     int $keys = `keyframe -sl -q -kc`;
  116.  
  117.     if( !$fromGraphEditor || ( $keys == 0 )) {
  118.         $cmd = ( $cmd + "-time \"" + $timeRange + "\" " );
  119.  
  120.         if( $fromGraphEditor || $doDriven ) {
  121.             $cmd = ( $cmd + "-float \"" + $timeRange + "\" " );
  122.         }
  123.  
  124.         // If there's a time specified, always add the option
  125.         //
  126.         if( $needOption ) {
  127.             $cmd = ( $cmd + "-option " + $option + " " );
  128.         }
  129.     }
  130.     
  131.     if( !$fromGraphEditor && ( $useChannelBox == 1 ) ) {
  132.         string $syntax[] = keySetOptionBoxCommon( { "copyKey", "unknown", 
  133.                                                     "channelBoxSyntax" } );
  134.         if( size( $syntax[0] ) == 0 ) {
  135.             $cmd = "";
  136.             warning( "No channels selected in channel box" );
  137.         } else {
  138.             $cmd = ( $cmd + "-hierarchy " + $hierarchy + " " );
  139.  
  140.             $cmd = $cmd + $syntax[0];
  141.         }
  142.     }
  143.     else if( $members != "" ) {
  144.         // Only add the selection connection to the cmd if
  145.         // there are NO active keys (in the graph editor),
  146.         // or we're not called from the graphEditor.
  147.         //
  148.         if( $keys == 0 || !$fromGraphEditor ) {
  149.             if ($members == "{}") {
  150.                 $cmd = "";
  151.                 warning ("No objects selected to copy keys");
  152.             }
  153.             else {
  154.                 $cmd = ($cmd + 
  155.                     "-hierarchy " + $hierarchy + " " +
  156.                     "-controlPoints " + $doControlPoints + " " +
  157.                     "-shape " + $doShapes + " " +
  158.                     $members
  159.                  );
  160.             }
  161.         }
  162.     }
  163.     else {
  164.         $cmd = ( $cmd + 
  165.                  "-animation objects " +  
  166.                  "-hierarchy " + $hierarchy + " " +
  167.                  "-controlPoints " + $doControlPoints + " " +
  168.                  "-shape " + $doShapes + " " );
  169.     }
  170.  
  171.     if( $cmd == "" ) {
  172.         return 0;
  173.     } else {
  174.         return evalEcho( $cmd );
  175.     }
  176. }
  177.  
  178.